/**
 * Created by jiaaobo on 16/7/27.
 */


import { Toast,Indicator} from 'mint-ui';

var UI = {

    toast : function(content){
      Toast({
        message: content,
        position: 'bottom'
      });
    },

    loginPage:function () {
        HybridJS.navigation.page.toNativePage(CONST.NATIVE_PAGE.LOGIN);
    },

    alert : function(content){
        HybridJS.ui.dialog.alert({
            message : content,
            okButtonText : "确定"
        })
    },

  loading : function(type){
    if(type == "show"){
      Indicator.open({
        text: '加载中...',
        spinnerType: 'snake'
      });
    }
    else{
      Indicator.close();
    }
  },

    cacheImage : function(imgUrl,callBack){
        var img = new Image();

        img.src = imgUrl;

        if(img.complete){
            console.log("缓存");
            callBack && callBack(img);
            return;
        }
        img.onload = function(){
            callBack && callBack(img);
        }
    }

};

module.exports = UI;
